# 临时测试脚本
import socket
import ssl


def test_connectivity():
    host = "tingwu-realtime-cn-beijing.aliyuncs.com"
    port = 443

    try:
        # 创建TCP连接
        sock = socket.create_connection((host, port), timeout=10)
        print(f"TCP connection to {host}:{port} successful")

        # 创建SSL上下文
        context = ssl.create_default_context()
        ssl_sock = context.wrap_socket(sock, server_hostname=host)

        print(f"SSL handshake with {host}:{port} successful")
        ssl_sock.close()
        return True
    except Exception as e:
        print(f"Connection failed: {str(e)}")
        return False


if test_connectivity():
    print("Network connectivity OK")
else:
    print("Network connectivity issues detected")